/*
 * User: user
 * Date: 15/12/2007
 * Time: 23:00:10
 */
package org.conann.metadata.records;

import com.google.common.collect.Lists;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.List;

public class MethodRecord extends BehaviorRecord<Method> {

    private final Class<?> returnedType;

    public MethodRecord(final Method method) {
        super(method);
        returnedType = method.getReturnType();
    }

    @Override
    protected List<Parameter<Method>> resolveParameters() {
        Method method = getMethod();
        List<Parameter<Method>> params = Lists.newArrayListWithExpectedSize(4);
        for (int i = 0; i < method.getParameterTypes().length; i++) {
            final MethodParameter param = new MethodParameter(method, i);
            params.add(param);
        }
        return Collections.unmodifiableList(params);
    }

    public Class<?> getReturnedType() {
        return returnedType;
    }

    public Method getMethod() {
        return getElement();
    }
}